import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../res/colors.dart';
import '../res/dimens.dart';
import '../utils/widget_utils.dart';

class ButtonProgressView {
  static Widget crateCupertinoView(
    String title, {
    Function cupertinoCall,
    bool isShow: false,
    bool value: true,
    // Color gradientColor01: Colours.main_01,
    // Color gradientColor02: Colours.main_01,
    Color textColor: Colors.white,
    Color blackColor,
    double circular: 25.0,
    double horizontalPadding: 16,
    //Color circularColor: Colours.main_01
  }) {
    return Container(
      color: Colors.transparent,
      child: Stack(
        children: <Widget>[
          // Offstage(
          //offstage: isShow,
          // child:
          Opacity(
            opacity: 1,
            child: Align(
              child: buildLoginBtnProvide(title,
                  cupertinoCall: cupertinoCall,
                  // gradientColor01: gradientColor01,
                  // gradientColor02: gradientColor02,
                  textColor: textColor,
                  circular: circular,
                  // circularColor: circularColor,
                  horizontalPadding: horizontalPadding,
                  blackColor: blackColor),
            ),
          ),
          // ),
          // Offstage(
          //   offstage: value,
          //   child: Opacity(
          //     opacity: 1,
          //     child: Align(
          //       child: Padding(
          //         child: WidgetUtils.buildLoginProgress(),
          //         padding: const EdgeInsets.only(bottom: 16),
          //       ),
          //     ),
          //   ),
          // ),
        ],
      ),
    );
  }

  static Widget buildLoginBtnProvide(String title,
      {Function cupertinoCall,
      // Color gradientColor01: Colours.botton_02,
      // Color gradientColor02: Colours.botton_01,
      Color textColor: Colors.white,
      Color blackColor,
      // Color circularColor,
      double horizontalPadding,
      double circular}) {
    return GestureDetector(
      onTap: () {
        cupertinoCall();
      },
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: horizontalPadding),
        alignment: Alignment.center,
        height: 48,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(circular),
          border: Border.all(
              width: 1,
              color: null == blackColor ? Colours.themeColor : blackColor),
          gradient: LinearGradient(colors: [
            null == blackColor ? Colours.themeColor : blackColor,
            null == blackColor ? Colours.themeColor : blackColor,
          ]),
          // boxShadow: [
          //阴影
//              BoxShadow(

//                  color: Colours.main_02,
//                  offset: Offset(0.0, 4.0),
//                  blurRadius: 13.0)
          // ]
        ),
        child: buildLoginChild(title, textColor: textColor),
      ),
    );
  }

  /// 登录按钮内部的 child
  ///
  /// 当请求进行时 [value.loading] 为 true 时,显示 [CircularProgressIndicator]
  /// 否则显示普通文本
  static Widget buildLoginChild(String title, {Color textColor: Colors.white}) {
    return FittedBox(
      fit: BoxFit.scaleDown,
      child:
          WidgetUtils.getTextColorView(title, textColor, Dimens.FONT_SIZE_16),
    );
  }
}
